﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;


namespace NMVN.Common
{
    public class AutoCompleteComboBoxColumn : DataGridViewTextBoxColumn
    {
        private string _ValueMember = "";
        private string _DisplayMember = "";
        private DataTable _DataSource = null;

        public AutoCompleteComboBoxColumn()
        {
            AutoCompleteComboBoxCell cell = new AutoCompleteComboBoxCell();
            base.CellTemplate = cell;
            //base.SortMode = DataGridViewColumnSortMode.Automatic;
        }

        private AutoCompleteComboBoxCell AutoCompleteComboBoxCellTemplate
        {
            get
            {
                AutoCompleteComboBoxCell cell = this.CellTemplate as AutoCompleteComboBoxCell;
                if (cell == null)
                    throw new InvalidOperationException("DataGridViewAccGridComboBoxColumn does not have a CellTemplate.");
                return cell;
            }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override DataGridViewCell CellTemplate
        {
            get
            {
                return base.CellTemplate;
            }
            set
            {
                AutoCompleteComboBoxCell cell = value as AutoCompleteComboBoxCell;
                if (value != null && cell != null)
                    throw new InvalidCastException("Value provided for CellTemplate must be of type DataGridViewAccTextBoxCell or derive from it.");
                base.CellTemplate = value;
            }
        }  

        public string ValueMember
        {
            get
            {
                return _ValueMember;
            }
            set
            {
                _ValueMember = value;
            }
        }

        public string DisplayMember
        {
            get
            {
                return _DisplayMember;
            }
            set
            {
                _DisplayMember = value;
            }
        }

        public DataTable DataSource
        {
            get
            {
                return _DataSource;
            }
            set
            {
                _DataSource = value;
            }
        }
           

    }
}
